package com.example.service.impl;

import com.example.dao.ManagerMapper;
import com.example.dao.OrderMapper;
import com.example.entity.*;
import com.example.service.OrderService;
import com.example.utils.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.Date;
import java.util.List;

public class OrderServiceImpl implements OrderService {
    private final OrderMapper mapper;
    private final SqlSession sqlSession;

    public OrderServiceImpl(SqlSession sqlSession) {
        this.sqlSession = sqlSession;
        this.mapper = sqlSession.getMapper(OrderMapper.class);
    }
    public void commit() {
        sqlSession.commit();
    }

    public void rollback() {
        sqlSession.rollback();
    }
    @Override
    public int deleteOrder(int o_id) { return mapper.deleteOrder(o_id); }

    @Override
    public void updateAddEconomySpace(int f_id) { mapper.updateAddEconomySpace(f_id); }

    @Override
    public void updateAddFirstSpace(int f_id) { mapper.updateAddFirstSpace(f_id); }

    @Override
    public void updateAddBusinessSpace(int f_id) { mapper.updateAddBusinessSpace(f_id); }

    @Override
    public void updatePassengerOrderNum(int passenger_id) { mapper.updatePassengerOrderNum(passenger_id); }

    @Override
    public Passenger getPassengerByPassengerId(int passenger_id) { return mapper.getPassengerByPassengerId(passenger_id); }

    @Override
    public Flight getFlightByFlightId(int f_id) { return mapper.getFlightByFlightId(f_id); }

    @Override
    public String getFlightModelByFlightId(int f_id) { return mapper.getFlightModelByFlightId(f_id); }

    @Override
    public Plane getPlaneByPlaneModel(String p_model) { return mapper.getPlaneByPlaneModel(p_model); }

    @Override
    public Date getFlightDateByFlightId(int f_id) { return mapper.getFlightDateByFlightId(f_id); }

    @Override
    public String getFlightStatusByFlightId(int f_id) { return mapper.getFlightStatusByFlightId(f_id); }

    @Override
    public String getPassengerIDcardByPid(int p_id) { return mapper.getPassengerIDcardByPid(p_id); }
    @Override
    public double getOrderMoneyByOid(int o_id) { return mapper.getOrderMoneyByOid(o_id); }
    @Override
    public double getBankMoneyByUserIDcard(String u_ID_card) { return mapper.getBankMoneyByUserIDcard(u_ID_card); }
    @Override
    public int updateOrderStatus(int o_id) { return mapper.updateOrderStatus(o_id); }
    @Override
    public int updatePassengerOrderNumByPid(int p_id) { return mapper.updatePassengerOrderNumByPid(p_id); }
    @Override
    public int updateBankMoneyByUserIDcard(String u_ID_card, double money) { return mapper.updateBankMoneyByUserIDcard(u_ID_card,money); }

    //订单详情

    @Override
    public Order getOrderByOrderId(int order_id) {
        return mapper.getOrderByOrderId(order_id);
    }
    @Override
    public List<Ticket> getTicketByOrderId(int order_id) {
        return mapper.getTicketByOrderId(order_id);
    }
    @Override
    public List<Passenger> getPassengerListByOrderId(int order_id) {
        return mapper.getPassengerListByOrderId(order_id);
    }
    @Override
    public List<Plane> getPlaneListByFId(int f_id) {
        return mapper.getPlaneListByFId(f_id);
    }
}
